package com.yufeng.collaboration.service.impl;


import com.yufeng.collaboration.config.RabbitMQConfig;
import com.yufeng.collaboration.entity.Document;
import com.yufeng.collaboration.service.MessageService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public void sendDocumentUpdateMessage(Document document) {
        try {
            rabbitTemplate.convertAndSend(RabbitMQConfig.EXCHANGE_NAME, RabbitMQConfig.ROUTING_KEY, document);
        } catch (Exception e) {
            // 可添加更详细的日志记录
            e.printStackTrace();
        }
    }
}    